package com.bootdo.mall_part.dao;

import com.bootdo.mall_part.domain.MallEvaluate;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 
 * @author lujingqian
 * @email 2100272728@qq.com
 * @date 2019-11-12 16:18:51
 */
@Mapper
public interface MallEvaluateDao {

	MallEvaluate get(Long id);
	
	List<MallEvaluate> list(Map<String,Object> map);
	
	int count(Map<String,Object> map);
	
	int save(MallEvaluate mallEvaluate);
	
	int update(MallEvaluate mallEvaluate);
	
	int remove(Long id);
	
	int batchRemove(Long[] ids);


	List<MallEvaluate> getByGoodsId(Map<String, Object> map);

//	@Select("select count(*) from me_mall_evaluate where goods_id = #{goodsId} and parent_id = 0")
	Integer getByGoodsIdCount(Map<String, Object> map);

	List<MallEvaluate> getUnreadFather(@Param("list") Set<Long> list, @Param("offset")Integer offset, @Param("limit")Integer limit);

	int getUnreadFatherCount(@Param("list") Set<Long> list);

	List<MallEvaluate> getByFatherId(@Param("id") Long id);

	List<MallEvaluate> getSonList(Map<String, Object> param);

	@Update("update me_mall_evaluate set is_read = 2 where (grand_father_id = #{grandFatherId} or id = #{grandFatherId}) and id <= #{endId} and replier_id = #{replierId}")
	int setReadedDao(@Param("grandFatherId") Long grandFatherId, @Param("endId") Long endId, @Param("replierId")Long replierId);

	@Select("select * from me_mall_evaluate where replier_id = #{memberId} and is_read = 1")
	List<MallEvaluate> getUnreadAll(@Param("memberId")Long memberId);
}
